$(document).ready(function() {
	$("#pageSelection").bind("change",function(){
		$("#pageIndex").val($("#pageSelection").val());
		$("#searchResultDiv").load(getRootPath()+ "/MainMenu/members/searchResultPage.htm",$("#memberForm").serializeArray());
	});
	
	$("#previousButton").bind("click",function(){
		$("#pageIndex").val($("#previousPageIndex").val());
		$("#searchResultDiv").load(getRootPath()+ "/MainMenu/members/searchResultPage.htm",$("#memberForm").serializeArray());
	});
	
	$("#nextButton").bind("click",function(){
		$("#pageIndex").val($("#nextPageIndex").val());
		$("#searchResultDiv").load(getRootPath()+ "/MainMenu/members/searchResultPage.htm",$("#memberForm").serializeArray());
	});
	
	
	$( "#progressbar" ).dialog({
		autoOpen:false,
		width:100,
		height:50,
		modal:true
	});

});

function edit(id) {
	
	$.getJSON(getRootPath()+ "/MainMenu/members/loadMember.htm",{memberID:id},function(data){
		$("#memberCardNumber").val(data.member.memberCardNumber);
		$("#idCardNumber").val(data.member.idCardNumber);
		$("#memberName").val(data.member.name);
		$("#phoneNumber").val(data.member.phoneNumber);
		$("#address").val(data.member.address);
		$("#costAmount").val(data.member.goodsPrice);
		$("#profitPercent").val(data.member.profitReturnPercent);
		$("#profitAmount").val(data.member.profitReturnAmount);
		$("#createDate").val(data.member.createDateString);
		$("#description").val(data.member.description);
		$("#id").val(data.member.id);
		$("#operatorID").attr("value",data.member.operatorID);
		$("#memberID").attr("value",data.member.memberID);
		$("#goodsID").attr("value",data.member.goodsID);
		$("#id").attr("value",data.member.id);
		$( "#editDiv" ).dialog("open");
	});
	
}
